<!DOCTYPE html><html><head><title>Ext.Number | Ext JS 4.0 Documentation</title><script type="text/javascript" src="../ext-all.js"></script><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../scrollbars.css" type="text/css"><link rel="stylesheet" href="../docs.css" type="text/css"><link id="styleCss" rel="stylesheet" href="../style.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script><link rel="stylesheet" href="../prettify.css" type="text/css"><!-- link(rel: 'stylesheet', href: req.baseURL + '/css/ext4.css', type: 'text/css')--><link rel="shortcut icon" type="image/ico" href="../favicon.ico"><!--[if IE]>
<style type="text/css">.head-band { display: none; }
.header { border: 0; top: 0; left: 0px; background: url(../header.gif) repeat-x; }
.doc-tab .members .member a.more { background-color: #efefef; }
</style><link rel="stylesheet" href="/new/css/ie.css" type="text/css"><![endif]-->
</head><body id="ext-body" class="iScroll"><div id="notice" class="notice">For up to date documentation and features, visit 
<a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a></div><div class="wrapper"><div class="head-band"></div><div class="header"><h2><a href="../index.html">Sencha Documentation</a></h2></div><div id="search"><form><input type="text" placeholder="Search" id="search-field" autocomplete="off" name="q"></form><div id="search-box"></div></div><div id="treePanel"></div><div id="container"><script type="text/javascript">

    req = {
        liveURL: '.',
        standAloneMode: true,
        origDocClass: 'Ext.Number',
        docClass: 'Ext.Number',
        docReq: 'Ext.Number',
        version: '4.0',
        baseURL: '.',
        baseDocURL: '.',
        baseProdURL: '.'
    };

    clsInfo = {};



</script>

<script type="text/javascript" src="../search.js"></script>
<!--script type="text/javascript" src="/new/javascripts/app/examples.js"></script-->
<script type="text/javascript" src="../class_tree.js"></script>
<script type="text/javascript" src="../class_doc.js"></script>
<script type="text/javascript">
    req.source = 'Number3.html#Ext-Number';
    clsInfo = {"methods":["constrain","from","toFixed"],"cfgs":[],"properties":[],"events":[],"subclasses":[]};
    Ext.onReady(function() {
        Ext.create('Docs.classPanel');
    });
</script><div id="top-block" class="top-block"><h1 id="clsTitle" class="cls"><a href="../source/Number3.html#Ext-Number" target="_blank">Ext.Number</a></h1></div><div id="docContent"><div id="doc-overview-content"><div class="lft"><p>A collection of useful static methods to deal with numbers</p>
<div class="members"><div class="m-methods"><a name="methods"></a><div class="definedBy">Defined By</div><h3 class="mth p">Methods</h3><div id="method-constrain" class="member f ni"><a href="Ext.Number.html#method-constrain" rel="method-constrain" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Number.html" class="definedIn docClass">Ext.Number</a><br/><a href="../source/Number3.html#Ext-Number-method-constrain" class="viewSource">view source</a></div><a name="constrain"></a><a name="method-constrain"></a><a href="Ext.Number.html#" rel="method-constrain" class="cls expand">constrain</a>(
<span class="pre">Number number, Number min, Number max</span>)
 : Number</div><div class="description"><div class="short">Checks whether or not the current number is within a desired range.  If the number is already within the
range it is ...</div><div class="long"><p>Checks whether or not the current number is within a desired range.  If the number is already within the
range it is returned, otherwise the min or max value is returned depending on which side of the range is
exceeded. Note that this method returns the constrained value but does not change the current number.</p>
<h3 class="pa">Parameters</h3><ul><li><span class="pre">number</span> : Number<div class="sub-desc"><p>The number to check</p>
</div></li><li><span class="pre">min</span> : Number<div class="sub-desc"><p>The minimum number in the range</p>
</div></li><li><span class="pre">max</span> : Number<div class="sub-desc"><p>The maximum number in the range</p>
</div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Number</span>&nbsp; &nbsp;<p>The constrained value if outside the range, otherwise the current value</p>
</li></ul></div></div></div><div id="method-from" class="member ni"><a href="Ext.Number.html#method-from" rel="method-from" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Number.html" class="definedIn docClass">Ext.Number</a><br/><a href="../source/Number3.html#Ext-Number-method-from" class="viewSource">view source</a></div><a name="from"></a><a name="method-from"></a><a href="Ext.Number.html#" rel="method-from" class="cls expand">from</a>(
<span class="pre">Mixed value, Number defaultValue</span>)
 : Number</div><div class="description"><div class="short">Validate that a value is numeric and convert it to a number if necessary. Returns the specified default value if
it i...</div><div class="long"><p>Validate that a value is numeric and convert it to a number if necessary. Returns the specified default value if
it is not.</p>

<p>Ext.Number.from('1.23', 1); // returns 1.23
Ext.Number.from('abc', 1); // returns 1</p>
<h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Mixed<div class="sub-desc">
</div></li><li><span class="pre">defaultValue</span> : Number<div class="sub-desc"><p>The value to return if the original value is non-numeric</p>
</div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Number</span>&nbsp; &nbsp;<p>value, if numeric, defaultValue otherwise</p>
</li></ul></div></div></div><div id="method-toFixed" class="member ni"><a href="Ext.Number.html#method-toFixed" rel="method-toFixed" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Number.html" class="definedIn docClass">Ext.Number</a><br/><a href="../source/Number3.html#Ext-Number-method-toFixed" class="viewSource">view source</a></div><a name="toFixed"></a><a name="method-toFixed"></a><a href="Ext.Number.html#" rel="method-toFixed" class="cls expand">toFixed</a>(
<span class="pre">Number value, Number precision</span>)
 : void</div><div class="description"><div class="short"><p>Formats a number using fixed-point notation</p>
</div><div class="long"><p>Formats a number using fixed-point notation</p>
<h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Number<div class="sub-desc"><p>The number to format</p>
</div></li><li><span class="pre">precision</span> : Number<div class="sub-desc"><p>The number of digits to show after the decimal point</p>
</div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">void</span>&nbsp; &nbsp;
</li></ul></div></div></div></div></div></div></div><div id="pageContent"></div></div></div></div></body></html>